package com.bustle.product.dto.product;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.product.data.Product;
import com.bustle.product.dto.provider.DtoToProviderMapConverter;

@Local
public interface DtoToProductMapConverter extends MapConverter<ProductDto, Product>
{
  @Stateless
  public class DefaultDtoToProductMapConverter extends AbstractMapConverter<ProductDto, Product> implements DtoToProductMapConverter
  {
    @Override
    public void doMapping(ProductDto paramASource, Product paramADestination)
    {
      paramADestination.setCreationDate(paramASource.getCreationDate());
      paramADestination.setDescription(paramASource.getDescription());
      paramADestination.setIdProduct(paramASource.getIdProduct());
      paramADestination.setImage(paramASource.getImage());
      paramADestination.setLimitedDate(paramASource.getLimitedDate());
      paramADestination.setName(paramASource.getName());
      paramADestination.setPrice(paramASource.getPrice());
      paramADestination.setProductType(paramASource.getProductType());
      paramADestination.setProvider(dtoToProviderConverter.map(paramASource.getProvider(), paramADestination.getProvider()));
    }

    @Override
    protected Product build()
    {
      return new Product();
    }

    @EJB
    protected DtoToProviderMapConverter dtoToProviderConverter;
  }
}